package com.sinosoft.utils;

import com.sinosoft.dao.LdcodeMapper;
import com.sinosoft.domain.Ldcode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;

/**
 * @Author: WangShengJie
 * @Date: 2025/3/28
 */
@Component
@Slf4j
public class AddressUtils {

//    public static HashMap<String,String> firstLevelAddressCache = new HashMap<>();
//    public static HashMap<String,String> secondLevelAddressCache = new HashMap<>();
//    public static HashMap<String,String> thirdLevelAddressCache = new HashMap<>();
//
//    @Autowired
//    private LdcodeMapper ldcodeMapper;
//
//    @PostConstruct
//    public void getAddressCache(){
//        log.info("开始初始化地址缓存");
//        List<Ldcode> first = ldcodeMapper.findByCodeType("address","1");
//        List<Ldcode> second = ldcodeMapper.findByCodeType("address","2");
//        List<Ldcode> third = ldcodeMapper.findByCodeType("address","3");
//        for (Ldcode ldcode : first) {
//            String code = ldcode.getCode();
//            String address = ldcode.getCodeName();
//            firstLevelAddressCache.put(address,code);
//            System.out.println(ldcode);
//        }
//        for (Ldcode ldcode : second) {
//            String otherSign = ldcode.getOtherSign();
//            String code = ldcode.getCode();
//            String address = ldcode.getCodeName();
//            secondLevelAddressCache.put(otherSign+"_"+address,code);
//        }
//        for (Ldcode ldcode : third) {
//            String otherSign = ldcode.getOtherSign();
//            String code = ldcode.getCode();
//            String address = ldcode.getCodeName();
//            thirdLevelAddressCache.put(otherSign+"_"+address,code);
//        }
//        log.info("缓存结束,一级地址缓存长度:{},二级地址缓存长度:{},三级地址缓存长度:{}",firstLevelAddressCache.size(),secondLevelAddressCache.size(),thirdLevelAddressCache.size());
//    }
}
